// HTTPTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

BOOL Download(CString strServer, CString strObject, CHAR *pBuffer, DWORD &nSize)
{
	CInternetSession session(L"my session");

	CHttpConnection *pServer = NULL;
	CHttpFile *pFile = NULL;

	DWORD nRead = 0;
	BOOL bRet = FALSE;
	try
	{
		pServer = session.GetHttpConnection(strServer);
		pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject);
		pFile-> SendRequest();

		DWORD dwRet;
		pFile-> QueryInfoStatusCode(dwRet);
		if(dwRet == HTTP_STATUS_OK)
		{
			DWORD nThisRead = pFile->Read(pBuffer + nRead, nSize - nRead);
			while(nThisRead > 0)
			{
				nRead += nThisRead;
				nThisRead = pFile->Read(pBuffer + nRead, nSize - nRead);
			}
			nSize = nRead;
			bRet = TRUE;
		}
	}
	catch(CInternetException*   pEx)
	{
		pEx->GetErrorMessage((LPTSTR)pBuffer, nSize);
	}

	delete pFile;
	delete pServer;
	return TRUE;
}

struct Base
{
	DWORD dw;
};

struct Der : public Base
{
	DWORD dw2;
};

int _tmain(int argc, _TCHAR* argv[])
{
	Base *p = new Der;
	DWORD size = sizeof(*p);
	//HKEY hKey;
	//DWORD dwxxx;
	//LONG lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
	//	L"SOFTWARE\\Spy",
	//	0,
	//	NULL,
	//	REG_OPTION_NON_VOLATILE,
	//	KEY_READ | KEY_WRITE,
	//	NULL,
	//	&hKey,
	//	&dwxxx);
	//LONG lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
	//	L"SOFTWARE\\TortoiseSVN",
	//	0,
	//	KEY_READ,
	//	&hKey);
	//if(lRet != ERROR_SUCCESS)

	return 0;
}

